package com.ceba.test.webservice.entity;

import com.fasterxml.jackson.annotation.JsonFormat;

/**
 * 私钥存放方式
 * @author leeguang
 */
//@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum PrivateKeyType {

    /**
     * 存放于Windows密钥库中，仅用于Windows系统中
     */
    PK_WINDOWS_MY(1),

    /**
     * P12软证书文件，文件中同时有私钥和对应的公钥证书
     * 不合法，俗称软证书
     */
    PK_P12_FILE(2),

    /**
     * 龙脉key作为签名服务器
     */
    LM_KEY_SERVER(3);

    public static PrivateKeyType from(int type) throws Exception {
        switch (type) {
            case 1:
                return PK_WINDOWS_MY;
            case 2:
                return PK_P12_FILE;
            case 3:
                return LM_KEY_SERVER;
            default:
                throw new Exception("Not support PrivateKeyType " + type);
        }
    }

    PrivateKeyType(int type) {
        this.type = type;
    }

    private final int type;

}
